package com.grandstream.website.controller;

import java.util.List;

import javax.validation.Valid;
import javax.xml.ws.BindingType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.grandstream.website.domain.Sys_Operator;
import com.grandstream.website.service.Sys_OperatorServiceImpl;


/**
 * ClassName:OperatorController
 * @Description: TODO(用户管理controller) 
 * @author   czheng
 * @version 1.0 2011-5-18
 * @since 1.0
 * @see
 */
@Controller
@RequestMapping(value="/operator/*")
public class OperatorController {
	
	@Autowired
	private Sys_OperatorServiceImpl sys_OperatorServiceImpl;
	
	@RequestMapping(value="save",method=RequestMethod.POST)
	public  String save(@Valid Sys_Operator sys_Operator,BindingResult result){
		System.out.println(result+":  "+sys_Operator);
		if(result.hasErrors()){
			return "operator/input";
		}
		return "redirect:/operator/list";
	}
	
	@RequestMapping(value="input")
	public String input(Model model){
		model.addAttribute(new Sys_Operator());
		return "operator/input";
	}
	
	@RequestMapping(value="list")
	public String list(Model model){
		List<Sys_Operator> list =sys_OperatorServiceImpl.getPage(null);
		model.addAttribute("list", list);
		return "operator/list";
	}
	
	
}
